# Contributor: Leon Marz <main@lmarz.org>
# Maintainer: Leon Marz <main@lmarz.org>
pkgname=pystring
pkgver=1.1.3
pkgrel=0
pkgdesc="C++ functions matching the interface and behavior of python string methods with std::string"
url="https://github.com/imageworks/pystring"
arch="all"
license="BSD-2-Clause"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/imageworks/pystring/archive/refs/tags/v$pkgver.tar.gz
	pystring.pc
	"

build() {
	# The repository doesn't have a good build system
	g++ -o libpystring.so.1.1 $CXXFLAGS $LDFLAGS -fPIC -shared -Wl,-soname,libpystring.so.1 pystring.cpp
	sed -i "s/@VERSION@/$pkgver/g" ../pystring.pc
}

check() {
	g++ -o test $CXXFLAGS $LDFLAGS -DPYSTRING_UNITTEST=1 pystring.cpp test.cpp
	./test
}

package() {
	mkdir -p "$pkgdir/usr/lib/pkgconfig"
	mkdir -p "$pkgdir/usr/include"

	mv libpystring.so.1.1 "$pkgdir/usr/lib"
	ln -s "libpystring.so.1.1" "$pkgdir/usr/lib/libpystring.so.1"
	ln -s "libpystring.so.1" "$pkgdir/usr/lib/libpystring.so"
	mv ../pystring.pc "$pkgdir/usr/lib/pkgconfig"

	mv pystring.h "$pkgdir/usr/include"
}

sha512sums="
a46bb2e96d6eb351a4a8097cde46ac2877d28e88f9e57e0ac36c42e8fc8543517c4be70306a01e2f88a891fc53c612494aeb37f47a200d94b8e1b050ed16eff6  pystring-1.1.3.tar.gz
b7b37d7b6b4d1dc5f745f047082d7629fe430198d0a1dee3d00147e8c638efc41e2af831da913c221099e8a944b8263fa7a7e8e0f0cc10f0fe99a01b46674692  pystring.pc
"
